#!/bin/bash
#注意运行该脚本之前确认自己已经点击了扩展安装的按钮
#虚拟光盘已经被插入
#要确保安装了gcc make 以及linux-kernel-devel
res=`command -v gcc`
if [ -z $res ]
then
	echo "need to install gcc first..."
	sudo yum install gcc
fi

res=`command -v make`
if [ -z $res ]
then
	echo "need to install make first..."
	sudo yum install make
fi

res=`sudo rpm -qa kernel-devel`
if [ -z $res ]
then
	echo "need to install kernel-devel..."
	sudo yum install kernel-devel
fi

if [ -e /dev/cdrom ]
then
	if [ -d /media/cdrom ]
	then
		sudo mkdir /media/cdrom
	fi
	sudo mount /dev/cdrom /media/cdrom
else
	echo "need cdrom to insert vbox disk."
	exit 1
fi

ln -s /usr/src/kernel/$(`uname -r`) /usr/src/linux
cd /media/cdrom
#对于vbox 4.20就运行这个程序
sudo ./VBoxLinuxAdditions.run

